package entity.item;

import model.ModelFactory;

import org.lwjgl.util.vector.Vector3f;

import entity.Entity;

/**
 * 
 * @author Jevgeni Krutov
 *
 */
public final class Item extends Entity {
	private boolean isTaken = false;
	private ItemType type;

	public Item(Vector3f position, Vector3f rotation, int w,ItemType type) {
		super(position, rotation);
		
		this.type = type;
		setSingleW(w);
		
		switch(type) {
			case ROCKET:
				this.model = ModelFactory.getModelInstance("assets/rocket.obj");
				break;
			case MEDKIT:
				this.model = ModelFactory.getModelInstance("assets/medkit.obj");
				break;
			case ENERGY:
				this.model = ModelFactory.getModelInstance("assets/energy.obj");
				break;
			case EXIT:
				this.model = ModelFactory.getModelInstance("assets/exit.obj");
				break;
		}
	}
	
	/**
	 * handles rotation of item around y-axis
	 */
	@Override
	public void changeSpeedAndMove(long elapsedTime) {
		rotation.y = (rotation.y + 0.1f * elapsedTime) % 360f; //modulus		
		invalidateMatrix();
	}
	
	@Override
	public boolean isAlive() {
		return !isTaken;
	}
	
	public void removeItem() {
		isTaken = true;
	}
	
	@Override
	public boolean isItem() {
		return true;
	}

	public ItemType getType() {
		return type;
	}
}
